package routines

import (
	"github.com/kataras/golog"
	"os"
	"os/signal"
	"syscall"
	"time"
)

// WaitExit 退出程序。
func WaitExit(code int) {
	// 等待退出信号
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
	<-sigs

	golog.Info("oh my god, application exited")

	exit(code)
}

// exit 退出程序。
func exit(code int) {
	time.Sleep(1 * time.Second)
	os.Exit(code)
}
